<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    async function a1() {
      console.log('a1 start')
      await a2()
      // #3
      console.log('a1 end')
    }
    async function a2() {
      console.log('a2')
    }
    console.log('script start')
    setTimeout(() => {
      // #1
      console.log('setTimeout')
    }, 0)
    Promise.resolve().then(() => {
      // #2
      console.log('promise1')
    })
    a1()

    let promise2 = new Promise((resolve) => {
      resolve('promise2.then')
      console.log('promise2')
    })
    promise2.then(res => {
      // #4
      console.log(res)
      Promise.resolve().then(() => {
        // #5
        console.log('promise3')
      })
    })
    console.log('script end')
  </script>
</body>

</html>